package org.feng.clog.utils;

import org.feng.clog.AbstractProcessorTemplate;
import org.feng.clog.ProcessorContext;
import org.feng.clog.ProcessorFactory;

/**
 * 管理工具
 *
 * @author feng
 */
public class ManagerUtil {
    public static <R, T> R handle(ProcessorContext<T> context) {
        AbstractProcessorTemplate<T, R> processor = ProcessorFactory.getProcessor(context.getAction());
        if (processor == null) {
            throw new RuntimeException("未找到 " + context.getAction() + "对应的处理器");
        }
        return processor.start(context);
    }
}
